package com.zc.framework.spring.aspect;

import java.util.concurrent.TimeUnit;
import java.util.concurrent.locks.Lock;

/**
 * Created by zc on 2017/1/20.
 */
//@Aspect
public class RedisRequestLockInterceptor extends AbstractRequestLockInterceptor {

//    @Autowired
    private RedissonService redissonService;

    private RedissonClient getRedissonClient(){
        return this.redissonService.getRedisson();
    }

    @Override
    protected Lock getLock(String key) {
        return this.getRedissonClient().getLock(key);
    }

    @Override
    protected boolean tryLock(long waitTime, long leaseTime, TimeUnit unit,Lock lock) throws InterruptedException {
        return ((RedisLock)lock).tryLock(waitTime,leaseTime,unit);
    }


}
